import Vue from 'vue'
import App from './App.vue'

import router from './router'
import store from './store'


import http from './util/http'
Vue.prototype.$http = http

import Cookies from 'js-cookie'
Vue.prototype.$cookies = Cookies;

Vue.config.productionTip = false

// 引入ElmentUi框架
import ElementUI from 'element-ui';
import "element-ui/lib/theme-chalk/index.css";
Vue.use(ElementUI);


// 新版本
// 永远pedding的promise
/* Vue.prototype.$alwaysPendingPromise = new Promise(() => {});
Vue.prototype.$confirmEx = function(message, title, options) {
    return Vue.prototype.$confirm(message, title, options).catch(() => {
        return Vue.prototype.$alwaysPendingPromise;
    })
} */

// 老版
Vue.prototype.$confirmEx = function(message, title, options) {
    return new Promise((resolve, reject) => {
        Vue.prototype.$confirm(message, title, options).then(res => {
            resolve();
            // 如果点击确定，执行resolve 外层的promise状态转为成功
        }).catch(err => {
            // 点击取消进入catch，但是外层的promise 没有返回所以是peding状态
        });
    })
}

// 复位样式
import './assets/css/reset.css';
// 公共样式
import './assets/css/public.css';

import toast from "@/components/Toast"


new Vue({
    name: app,
    router,
    store,
    render: h => h(App),
}).$mount("#app");